Skip to main content

Bash

Code

Pipe output to file:

ls > output.txt

Save current Date in variable:

now=${date}

Print variable:

echo ${now}

Check if local git repo has changes:

if \[\[ \`git status --porcelain\` \]\]; then
echo 'CHANGES'
else
echo 'NO CHANGES'
fi

Two different ways to write if statements:

  1. with semicolon before then:
    if [ "Test" != 'Test' ]; then
echo '💬'
else
echo '💬'
  1. with no semicolon and new line before then
    if [ "Test" != 'Test' ] 
then
echo '💬'
else
echo '💬'